<template>
  <aplayer :audio="audio" :lrcType="3" fixed />
</template>

<script>
import Vue from "vue";
import APlayer from "@moefe/vue-aplayer";

Vue.use(APlayer);

export default {
  data() {
    return {
      audio: [
     
      ],
      // playlist:this.$store.state.serve
    };
  },
  // computed:{
  //   playlist(){
  //     return this.$store.state.serve

  //   }
  // },
  mounted() {
    this.$bus.$on('shuaxin',()=>{
      var music = [];
     this.$https.get("/play").then((res) => {
      // console.log(res.data);
      res.data.forEach((item) => {
        // console.log(item);
        var { id } = item;
        var {name, picUrl} = item.al;
        // console.log(id);
        this.$http.get(`/song/url?id=${id}`).then((res) => {
          // console.log(res.data.data[0].url);
          var { url } = res.data.data[0];
          music.push({
            id,
            name: name,
            artist: item.ar[0].name,
            cover: picUrl,
            url: url,
          });
          this.audio = music
        });
      });
    });
  })
    var music = [];
    this.$https.get("/play").then((res) => {
      // console.log(res.data);
      res.data.forEach((item) => {
        // console.log(item);
        var { id } = item;
        var { name, picUrl } = item.al;
        // console.log(id);
        this.$http.get(`/song/url?id=${id}`).then((res) => {
          // console.log(res.data.data[0].url);
          var { url } = res.data.data[0];
          music.push({
            id,
            name: name,
            artist: item.ar[0].name,
            cover: picUrl,
            url: url,
          });
          this.audio = music
        });
      });
    });
  },
};
</script>